using System;
using Slaks.Descriptions;

namespace Slaks.Filters
{
	/// <summary>
	/// Hebrew characters filter
	/// </summary>
   [ModuleDescription("Hebrew character filter","Slava Kisilevich")]
	public class HebrewFilter : AFilter
	{
	  protected static readonly int HebrewNotInRangeBegin = 0x590;
		protected static readonly int HebrewNotInRangeEnd = 0x5F0;
	  
	  protected static readonly int HebrewPunctuationPasseqWhiteSpace = 0x5c0;

	  protected static readonly int HebrewAccentEthantha = 0x591;
	  protected static readonly int HebrewPointRafe = 0x5bf;

	  protected static readonly int HebrewPointShinDot = 0x5c1;
		protected static readonly int HebrewMarkLowerDot = 0x5c5;

		protected static readonly int HebrewPointQamatsQatan = 0x5c7;


		public HebrewFilter()
		{
		}

		/// <summary>
		/// If the character is one that is defined as 'space' character, then return true
		/// Each language has its own characters that can be defined as space characters
		/// For example : in english it can be '\t', ' '
		/// </summary>
		/// <param name="ch">character to check</param>
		/// <returns>true/false</returns>
		public override bool IsWhiteSpace(char ch)
		{
			if (ch <= HebrewNotInRangeBegin || ch >= HebrewNotInRangeEnd) return true;
			if (ch == HebrewPunctuationPasseqWhiteSpace) return true;
			return false;
		}

		 public override bool IsEndOfSentencePunctuationMark(char ch)
		 {
			 if (ch == GeneralEndOfSentencePunctuationMarkDot ||
				 ch == GeneralEndOfSentencePunctuationMarkExclamation ||
				 ch == GeneralEndOfSentencePunctuationMarkQuestion) return true;

			 return false;
		 }

		 public override bool IsMiddleSentencePunctuationMark(char ch)
		 {
			 if (ch == GeneralMiddleOfSentencePunctuationMarkComma) return true;
			 return false;
		 }

		 /// <summary>
		 /// Skip the character without splitting the term
		 /// </summary>
		 /// <param name="ch">character to check</param>
		 /// <returns>true/false</returns>
		public override bool DoSkipCharInTerm(char ch)
		{
			 if (ch >= HebrewAccentEthantha && ch <= HebrewPointRafe) return true;
			 if (ch >= HebrewPointShinDot && ch <= HebrewMarkLowerDot) return true;
			 if (ch == HebrewPointQamatsQatan) return true;
			 return false;
		}

		/// <summary>
		/// Normalization of the character
		/// </summary>
		/// <param name="ch">character to be normalized</param>
		/// <returns>normalized character</returns>
		public override char Normalize(char ch)
		{
			return ch;
		}

		 public override string ToString()
		 {
			 return "Hebrew character filter";
		 }

	}
}
